<template>
  <!-- 顶部标题 -->
  <Header />
  <div class="back-page">
    <div class="announcement-page">
      <!-- 返回与标题 -->
      <div class="header">
        <el-link
          type="primary"
          @click="onCancel"
          class="back-link"
          icon="DArrowLeft"
          >返回</el-link
        >
        <span> 首页 / 帮助中心</span>
      </div>
      <div class="help-center">
        <div class="box-headerr">
          <span class="title">帮助中心</span>
        </div>
        <!-- 使用 el-table 显示数据 -->
        <el-table :data="helpLinks" style="width: 100%">
          <el-table-column label="指引名称">
            <template #default="scope">
              <span class="name" @click="handleRowClick(scope.row)">
                {{ scope.row.noticeTitle }}
              </span>
            </template>
          </el-table-column>

          <el-table-column label="发布日期" width="200">
            <template #default="scope">
              <span class="name" @click="handleRowClick(scope.row)">
                {{ moment(scope.row.createTime).format("YYYY-MM-DD") }}
              </span>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script setup>
import moment from "moment";
import { onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import { noticeList } from "@/api/helpNotice";
import Header from "../../components/Header.vue";

const router = useRouter();

const helpLinks = ref([]);

const handleRowClick = (row) => {
  router.push({
    path: "/helpDetail",
    query: {
      noticeId: row.noticeId,
    },
  });
};

const onCancel = () => {
  if (window.history.length > 1) {
    window.history.back(); // 返回上一页
  } else {
    router.push(`judgeProject?type=${route.query.type}`);
    window.location.reload(); // 刷新当前页面
  }
};

onMounted(() => {
  noticeList({ pageNum: 1, pageSize: 9999 }).then((res) => {
    if (res.code == 200) {
      helpLinks.value = res.rows;
    }
  });
});
</script>

<style scoped>
.back-page {
  min-height: calc(100vh - 56px);
  background: url("../../assets/f87147698f07020d4fea348f49da0166.png") no-repeat
    center center;
  background-size: cover;
}
.header {
  display: flex;
  align-items: center;
}
.header .logo {
  display: flex;
  align-items: center;
}
.header .logo span {
  margin-left: 16px;
  font-size: 18px;
  font-weight: bold;
}
.announcement-page {
  width: 76%;
  margin: auto;
  padding-top: 20px;
}

.header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #333;
}

.back-link {
  margin-right: 8px;
}
.help-center {
  border-radius: 8px;
  padding: 30px 10% 50px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  h3 {
    margin-bottom: 16px;
  }
}

.box-headerr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  /* border-bottom: 1px solid #ebeef5; */
  margin-bottom: 8px;
  .title {
    font-size: 18px;
    font-weight: bold;
  }

  .more {
    font-size: 14px;
  }
}

.el-table {
  margin-top: 16px;
  box-shadow: 0px 0px 30px #b7b7b7;
  min-height: 600px;
  background: linear-gradient(
    -45deg,
    #ddf1ff 0%,
    #f0f9ff 10%,
    #ffffff 20%,
    #ffffff 80%,
    #f0f9ff 90%,
    #ddf1ff 100%
  ) !important;
}

:deep(.el-table) {
  --el-table-row-hover-bg-color: transparent;
  --el-table-tr-bg-color: transparent;
  --el-table-header-bg-color: transparent;
  --el-table-border-color: transparent;
}
:deep(.el-table__header-wrapper *) {
  color: #000;
}
:deep(.el-table__header-wrapper) {
  font-weight: bold;
  color: #000;
  font-size: 16px;
  padding: 5px 0;
  border-bottom: 2px solid #ebedf3;
}
:deep(.el-table .cell) {
  padding: 0 25px;
}
:deep(.el-table__row:hover) {
  color: blue; /* 颜色变为蓝色 */
  cursor: pointer;
}
</style>
